package com.mit.service.maintenance.dao.impl;

import org.apache.log4j.Logger;

import com.mit.common.exception.NoRecordUpdateException;
import com.mit.common.maintenance.dto.OrganizationDTO;
import com.mit.service.core.dao.AbstractDAO;
import com.mit.service.maintenance.dao.IOrganizationDAO;

public class OrganizationDAOImpl extends AbstractDAO implements IOrganizationDAO {
	private static final Logger logger = Logger.getLogger(OrganizationDAOImpl.class);

	@Override
	public OrganizationDTO updateOrganization(OrganizationDTO organizationDTO) throws NoRecordUpdateException {
		logger.debug("organizationDTO: " + organizationDTO);
		int rs = getSqlMapClientTemplate().update("updateOrganization", organizationDTO);
		if(rs == 0) {
			throw new NoRecordUpdateException();
		}
		return organizationDTO;
	}
	
	@Override
	public OrganizationDTO retrieveOrganization(int id) {
		return (OrganizationDTO) getSqlMapClientTemplate().queryForObject("getOrganization", id);
	}
}
